<template>
  <!-- 版心  -->
  <el-container class="main-container">
    <!-- 1.左侧菜单栏 -->
    <el-aside width="200px">
      <div class="user-box">
        <img src="@/assets/logo.png" alt="" />
        <span>欢迎 </span>
      </div>
      <el-menu
        default-active="/home"
        class="el-menu-vertical-demo"
        background-color="#23262E"
        text-color="#fff"
        active-text-color="#409EFF"
        unique-opened
        router
        collapse-transition
      >
        <!--首页导航,不需要折叠-->
        <el-menu-item index="/home">
          <i class="el-icon-s-home"></i>
          <span slot="title">首页</span>
        </el-menu-item>
        <!--文章管理导航,需要折叠-->
        <el-submenu index="1">
          <template slot="title">
            <i class="el-icon-reading"></i>
            <span slot="title">文章管理</span>
          </template>
          <el-menu-item index="/art-cate">
            <i class="el-icon-menu"></i>
            <span slot="title">文章分类</span></el-menu-item
          >
          <el-menu-item index="/art-list">
            <i class="el-icon-menu"></i>
            <span slot="title">文章列表</span></el-menu-item
          >
        </el-submenu>
        <!--个人中心导航,需要折叠-->
        <el-submenu index="3">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span slot="title">个人中心</span>
          </template>
          <el-menu-item index="/user-info">
            <i class="el-icon-menu"></i>
            <span slot="title">基本资料</span></el-menu-item
          >
          <el-menu-item index="/user-avatar">
            <i class="el-icon-menu"></i>
            <span slot="title">更换头像</span></el-menu-item
          >
          <el-menu-item index="/user-pwd">
            <i class="el-icon-menu"></i>
            <span slot="title">重置密码</span></el-menu-item
          >
        </el-submenu>
      </el-menu>
    </el-aside>
    <!-- 2.右侧内容 -->
    <el-container>
      <!-- 2.1 右侧顶部栏 -->
      <el-header>
        <div class="logo"></div>
        <el-menu
        mode="horizontal"
          text-color="#5c5c5c"
          active-text-color="#409EFF"
        >
        <!--个人中心导航,需要折叠-->
          <el-submenu index="2">
            <template slot="title">
              <img src="@/assets/logo.png" alt="" class="avatar" />
              <span slot="title">个人中心</span>
            </template>
            <el-menu-item index="2-1">
              <span slot="title">基本资料</span>
              </el-menu-item>
            <el-menu-item index="2-2"
              ><span slot="title">更换头像</span>
              </el-menu-item>
            <el-menu-item index="2-3"
              ><span slot="title">重置密码</span>
              </el-menu-item>
          </el-submenu>
           <!--退出导航,不需要折叠-->
            <el-menu-item index="2"
            ><i class="el-icon-switch-button"></i>退出</el-menu-item>
        </el-menu>
      </el-header>
      <!-- 2.2 右侧内容 -->
      <el-main>
        <!--二级路由出口-->
        <router-view></router-view>
      </el-main>
      <!-- 2.3 右侧底部 -->
      <el-footer>© www.itheima.com - 黑马程序员</el-footer>
    </el-container>
  </el-container>
</template>

<script>
export default {
  name: "Main",
  data() {
    return {};
  },
};
</script>

<style lang="less" scoped>
.main-container {
  height: 100%;
  .el-aside {
    background-color: #23262e;
  }
  .el-header {
    padding: 0;
    display: flex;
    justify-content: space-between;
  }
  .el-main {
    overflow-y: scroll;
    height: 0;
    background-color: #f2f2f2;
  }
  .el-footer {
    background-color: #eee;
    font-size: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}

.avatar {
  border-radius: 50%;
  width: 35px;
  height: 35px;
  background-color: #fff;
  margin-right: 10px;
  object-fit: cover;
}

//右侧样式
.el-header {
  .logo {
    height: 45px;
    width: 150px;
    padding: 8px 0px;
    user-select: none;
    text-align: center;
    background: url("@/assets/images/logo.png") center center / 100px no-repeat
      rgb(85, 85, 85);
    border-radius: 3px;
    margin-left: 15px;
  }
}

// 左侧边栏用户信息区域
.user-box {
  height: 70px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
  user-select: none;
  img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: #fff;
    margin-right: 15px;
    object-fit: cover;
  }
  span {
    color: white;
    font-size: 12px;
  }
}

// 侧边栏菜单的样式
.el-aside {
  .el-submenu,
  .el-menu-item {
    width: 200px;
    user-select: none;
  }
}
</style>